<template>
	<view class="help-center">
		<!-- 顶部导航 -->
		<view class="header">
			<uni-icons type="left" size="20" @click="goBack" />
			<text class="title">帮助中心</text>
		</view>

		<!-- 搜索区域 -->
		<view class="search-section">
			<view class="search-box">
				<uni-icons type="search" size="20" color="#666" />
				<input type="text" placeholder="输入关键词搜索" v-model="searchKey" />
			</view>
			<view class="hot-tags">
				<text class="tag" v-for="(tag, index) in hotTags" :key="index">{{ tag }}</text>
			</view>
		</view>

		<!-- 分类区域 -->
		<view class="category-section">
			<view class="category-item" v-for="(category, index) in categories" :key="index"
				@click="handleCategoryClick(index)">
				<image class="category-icon" :src="category.icon" mode="aspectFit" />
				<text class="category-name">{{ category.name }}</text>
			</view>
		</view>

		<!-- 热门问题 -->
		<view class="hot-questions">
			<view class="section-title">热门问题</view>
			<view class="question-list">
				<view class="question-item" v-for="(question, index) in hotQuestions" :key="index"
					@click="handleQuestionClick(index)">
					<text class="question-text">{{ question.title }}</text>
					<uni-icons type="right" size="16" color="#999" />
				</view>
			</view>
		</view>

		<!-- 底部客服 -->
		<view class="contact-section">
			<button class="contact-btn" @click="contactService">
				<uni-icons type="headphones" size="20" color="#FFFFFF" />
				<text>在线客服</text>
			</button>
			<view class="service-info">
				<text class="phone">客服热线：400-888-8888</text>
				<text class="time">服务时间：9:00-22:00</text>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { ref } from 'vue';

	const searchKey = ref('');
	const hotTags = ref(['取件延误', '订单取消', '快递丢失', '收费标准']);

	const categories = ref([
		{
			name: '订单相关',
			icon: 'https://ai-public.mastergo.com/ai/img_res/2d23ee402413396251575c30000c0f8b.jpg'
		},
		{
			name: '配送说明',
			icon: 'https://ai-public.mastergo.com/ai/img_res/f76210adb7606b4e0ee73ea48bea8baf.jpg'
		},
		{
			name: '收费标准',
			icon: 'https://ai-public.mastergo.com/ai/img_res/d35890e0303de008d12fff6e83cd2dac.jpg'
		},
		{
			name: '账户安全',
			icon: 'https://ai-public.mastergo.com/ai/img_res/251b93ab5a3d1ab1ad74dd14509c02dc.jpg'
		}
	]);

	const hotQuestions = ref([
		{ title: '如何下单？', content: '' },
		{ title: '配送时效说明', content: '' },
		{ title: '订单取消规则', content: '' },
		{ title: '快递丢失赔付说明', content: '' },
		{ title: '如何修改收货地址？', content: '' }
	]);

	const goBack = () => {
		uni.navigateBack();
	};

	const handleCategoryClick = (index : number) => {
		uni.showToast({
			title: `功能开发中`,
			icon: 'none'
		});
	};

	const handleQuestionClick = (index : number) => {
		uni.showToast({
			title: `功能开发中`,
			icon: 'none'
		});
	};

	const contactService = () => {
		uni.showToast({
			title: '正在连接客服...',
			icon: 'none'
		});
	};
</script>

<style>
	page {
		height: 100%;
		background-color: #f5f5f5;
	}

	.help-center {
		min-height: 100%;
		padding-bottom: 240rpx;
		box-sizing: border-box;
	}

	.header {
		position: sticky;
		top: 0;
		display: flex;
		align-items: center;
		padding: 20rpx 30rpx;
		background-color: #ffffff;
		z-index: 100;
	}

	.title {
		margin-left: 30rpx;
		font-size: 16px;
		font-weight: 500;
		color: #333333;
	}

	.search-section {
		padding: 30rpx;
		background-color: #ffffff;
	}

	.search-box {
		display: flex;
		align-items: center;
		padding: 20rpx 30rpx;
		background-color: #f5f5f5;
		border-radius: 32rpx;
	}

	.search-box input {
		flex: 1;
		margin-left: 20rpx;
		font-size: 14px;
		color: #333333;
	}

	.hot-tags {
		display: flex;
		flex-wrap: wrap;
		margin-top: 20rpx;
	}

	.tag {
		margin: 10rpx 20rpx 10rpx 0;
		padding: 10rpx 20rpx;
		background-color: #f0f0f0;
		border-radius: 24rpx;
		font-size: 12px;
		color: #666666;
	}

	.category-section {
		display: flex;
		flex-wrap: wrap;
		padding: 30rpx;
		background-color: #ffffff;
		margin-top: 20rpx;
	}

	.category-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 25%;
		margin-bottom: 30rpx;
	}

	.category-icon {
		width: 80rpx;
		height: 80rpx;
		margin-bottom: 16rpx;
	}

	.category-name {
		font-size: 12px;
		color: #333333;
	}

	.hot-questions {
		margin-top: 20rpx;
		padding: 30rpx;
		background-color: #ffffff;
	}

	.section-title {
		margin-bottom: 30rpx;
		font-size: 16px;
		font-weight: 500;
		color: #333333;
	}

	.question-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 0;
		border-bottom: 1px solid #f0f0f0;
	}

	.question-text {
		font-size: 14px;
		color: #333333;
	}

	.contact-section {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 30rpx;
		background-color: #ffffff;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
	}

	.contact-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
		background-color: #1989fa;
	}

	.contact-btn text {
		margin-left: 10rpx;
		color: #ffffff;
	}

	.service-info {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.phone {
		margin-bottom: 10rpx;
		font-size: 14px;
		color: #333333;
	}

	.time {
		font-size: 12px;
		color: #999999;
	}
</style>